package com.company.vmpx.ui.home.presenter;


import com.dee.components.baserx.RxSchedulers;
import com.company.vmpx.api.HttpManager;
import com.company.vmpx.api.ResultEntity;
import com.company.vmpx.api.RxSubscriber;
import com.company.vmpx.ui.AppConstant;
import com.company.vmpx.ui.home.contract.HomeContract;
import com.company.vmpx.ui.home.entity.NewsBean;

import java.util.HashMap;


/**
 * 作者：Administrator on 2017/12/04 10:36
 * 当前类注释:
 * Presenter
 */
public class HomePresenter extends HomeContract.Presenter {

    @Override
    public void getWangYiNews(final int page) {
        //请求参数
        HashMap<String, String> param = new HashMap<>();
        param.put("page", page + "");
        param.put("count", AppConstant.pageSize + "");
        HttpManager.getInstance().getOkHttpUrlService().getWangYiNews(param)
                .compose(RxSchedulers.<ResultEntity<NewsBean>>io_main())
                .subscribe(new RxSubscriber<ResultEntity<NewsBean>>(this) {
                    @Override
                    public void _onNext(ResultEntity<NewsBean> data) {
                        mView.return_NewsData(data.getRows());
                    }

                    @Override
                    public void onErrorSuccess(int code, String message, boolean issuccess) {
                        mView.onErrorSuccess(code, message, issuccess, false);
                    }
                });
    }
}
